package cn.pku.ss.fa.ui.component.friends;

import java.util.List;

import javax.naming.InitialContext;

import org.zkoss.zk.ui.SuspendNotAllowedException;
import org.zkoss.zul.Div;
import org.zkoss.zul.Window;

import cn.pku.ss.fa.bean.BoardMessageBean;
import cn.pku.ss.fa.sessionbean.ArticleManagerLocal;
import cn.pku.ss.fa.sessionbean.BoardManagerLocal;
import cn.pku.ss.fa.ui.component.FriendsComponent;

public class DisplayNoticeComponent extends Div {

	private List<BoardMessageBean> boardMessages;

	public List<BoardMessageBean> getBoardMessages() {
		return boardMessages;
	}

	public void setBoardMessages(List<BoardMessageBean> boardMessages) {
		this.boardMessages = boardMessages;
	}

	public DisplayNoticeComponent() {
		try {
			InitialContext ctx = new InitialContext();
			BoardManagerLocal boardManager = (BoardManagerLocal) ctx
					.lookup("FriendsAnywhere/BoardManager/local");
			
			int userId = FriendsComponent.getFriendIdInFriendPage();
			boardMessages = boardManager.getBoardMessagesByUserId(userId);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void leaveMessage() throws SuspendNotAllowedException,
			InterruptedException {
		Window newReply = (Window) getPage().getFellow("newMessage");
		newReply.doModal();
	}
}
